# -*- coding: utf-8 -*-
# flake8: noqa

from qiniu import Auth, put_file, etag, urlsafe_base64_encode
import qiniu.config
def qiniu_upload(path,name):
    #需要填写你的 Access Key 和 Secret Key
    
    access_key = 'Qa1ff413baAEt7P4R_s7SfLq0eKa7Ah4n7Eva5nY'
    secret_key = '88AXlxSrWlk-a5d5KVPjXBbSFar1wKWl83N5Upke'
    
    #构建鉴权对象
    q = Auth(access_key, secret_key)
    
    #要上传的空间
    bucket_name = 'sharefood'
    
    #上传到七牛后保存的文件名
    key = name
    
    #生成上传 Token，可以指定过期时间等
    token = q.upload_token(bucket_name, key, 3600)
    
    #要上传文件的本地路径
    localfile = path 
    
    ret, info = put_file(token, key, localfile)
#    print(info)
    return info
#    assert ret['key'] == key
#    assert ret['hash'] == etag(localfile)
